import { Directive, DirectiveBinding } from 'vue'
import img from '@/assets/common/head.jpg'
import { useStore } from '@/store/user'

export const imgError :Directive=(el:HTMLInputElement,binding:DirectiveBinding)=>{
  console.log(el,binding)
  el.onerror=() => el.src=binding.value || img
}

export const allow :Directive=(el:HTMLElement,binding:DirectiveBinding)=>{
  console.log(el,binding)
  const store =useStore()
  const points=store.useInfo?.roles.points
  console.log('points',points)
  if(!points?.includes(binding.value)) el.style.display='none'
}
